package dapps.service.monitor;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.Page;
import org.springside.modules.orm.hibernate.EntityManager;
import org.springside.modules.utils.DateUtils;

import dapps.dao.monitor.MonitorDao;
import dapps.entity.monitor.Cominput;
import dapps.entity.monitor.Fieldvalue;
import dapps.entity.monitor.Indicator;
import dapps.entity.monitor.Servicedata;
import dapps.entity.monitor.Servicemain;
import dapps.entity.monitor.Servicepredi;
import dapps.entity.monitor.Smvalue;
import dapps.entity.user.User;

@Service
// 默认将类中的所有函数纳入事务管理.
@Transactional
public class MonitorManager extends EntityManager<Servicemain, Long> {
	@Autowired
	private MonitorDao mDao;

	@Override
	protected MonitorDao getEntityDao() {
		return mDao;
	}
	public Servicedata getData(Long mainid) {
		return mDao.getData(mainid);		
	}
	
	public Servicepredi getDatapredi(Long mainid) {
		return mDao.getDatapredi(mainid);
	}

	
	@Override
	public void delete(Long id) {
		mDao.delete(id);
	}
	
	public void delete(Servicemain sm) {
		mDao.delete(sm);
	}
	public void saveService(Servicemain sm,Servicedata sd,Servicepredi sp) {
		sm.setUpdateDate(DateUtils.getCurrentDateTime());
		mDao.saveService(sm, sd, sp);
	}

	
	public Page<Cominput> getSmPageByDate(Page<Cominput> page ,String reportDate,Integer usercode,Long districtid){
		return  mDao.getSmPageByDate(page, reportDate, usercode,districtid);
	}
	public List<User> getSmsPageByDate(String reportDate,Integer usercode,Long districtid){
		return  mDao.getSmsPageByDate(reportDate, usercode,districtid);
	}
	public int getInputCount(String reportDate,Long districtid) {
		return  mDao.getInputCount(reportDate,districtid);
	}
	public Long getSmId(String reportDate,Long userid) {
		return  mDao.getSmId(reportDate, userid);
	}
	public Cominput getSmPageByDate(String reportDate,Integer userid,Long districtid) {
		return  mDao.getSmPageByDate(reportDate,userid,districtid);
	}
	public Map<String,Integer> getStaticsPredi(String reportDate,Long typeid,Long districtid){
		return  mDao.getStaticsPredi(reportDate,typeid,districtid);
	}
	public Map<String,Double> getStaticsData(String reportDate,Long typeid,Long districtid){
		return mDao.getStaticsData(reportDate,typeid,districtid);
	}
	public Map<String,Double> getStaticsLastmonth(String reportDate,Long typeid,Long districtid) {
		return mDao.getStaticsLastmonth(reportDate,typeid,districtid);
	}
	public List<Indicator> getStaticsIndicator(String reportDate,Long typeid,Long districtid) {
		return mDao.getStaticsIndicator(reportDate, typeid,districtid);
	}
	public List<Indicator> getStaticsIndicators(String reportDate,Long districtid) {
		return mDao.getStaticsIndicators(reportDate,districtid);
	}
	public List<Fieldvalue> getStaticsOthers(String reportDate,String[] fields,String otherno,String otherrank,Long typeid,Long districtid) {
		return mDao.getStaticsOthers(reportDate,fields,otherno,otherrank,typeid,districtid);
	}
	public Page<Smvalue> getRank(Page<Smvalue> page, String reportDate,Long typeid,Long districtid) {
		return mDao.getRank(page, reportDate, typeid,districtid);
	}
	public List<Smvalue> getRankList(Page<Smvalue> page, String reportDate,Long typeid,Long districtid){
		return mDao.getRankList(page, reportDate, typeid, districtid);
	}
	public List<Fieldvalue> getProblem(String reportDate, String field,Long districtid) {
		return mDao.getProblem(reportDate, field, districtid);
	}
}
